<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" >
<head th:replace="main/_fragments :: header(~{::title},~{},~{::meta})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>博客友情链接页面</title>
</head>
<body>

<!--头部导航-->
<div th:replace="main/_backEnd :: header_backEnd(4)"></div>

<!--二级导航-->
<div class="ui attached pointing menu">
    <div class="ui container">
        <a th:href="@{/admin/link}" target="_blank" class="active teal item">发布</a>
        <a th:href="@{/admin/links}" target="_blank" class="item">列表</a>
    </div>
</div>

<!--中间内容   ctrl+enter先输入内容然后注释-->
<!--div +tab 快速补全代码-->
<div id="middle-content" class="m-container-small m-padded-tb-big">
    <div class="container">
        <!--表格列表-->
        <table class="ui single line table">
            <thead>
            <tr class="center aligned">
                <th>Id</th>
                <th>链接名称</th>
                <th>链接地址</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody th:each="list : ${linkBeans}">
            <tr class="center aligned">
                <td th:text="${list.id}"></td>
                <td th:text="${list.friendName}"></td>
                <td th:text="${list.url}"></td>
                <td>
                    <a href="#" th:href="@{/admin/link/}+${list.id}" class="ui mini teal basic button">编辑</a>
                    <a href="#" th:id="'btnDel'+${list.id}" th:attr="data-url=@{/admin/link/}+${list.id}" onclick="deleteBtn(this)" class="ui mini red basic button">删除</a>
                    <form id="deleteFormId" method="post">
                        <input type="hidden" name="_method" value="delete">
                    </form>
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr>
                <th colspan="1">
                    <a th:href="@{/admin/link}" class="ui mini teal basic button">
                        <i class="plus icon"></i>
                        新增
                    </a>
                </th>
                <th colspan="4">
                    <div class="ui right floated pagination menu" th:if="${linkBeans.totalPages>1}">
                        <a th:unless="${linkBeans.first}" class="icon item" th:href="@{/admin/links(page=${linkBeans.number}-1)}">
                            <i class="left chevron icon"></i>
                        </a>
                        <a th:unless="${linkBeans.last}" class="icon item" th:href="@{/admin/links(page=${linkBeans.number}+1)}">
                            <i class="right chevron icon"></i>
                        </a>
                    </div>
                </th>
            </tr>
            </tfoot>
        </table>
    </div>
</div>

<div th:replace="main/_fragments :: toTop"></div>
<!--尾部-->
<footer th:replace="main/_fragments :: footer"></footer>


<!--引入js-->
<th:block th:replace="main/_fragments :: script"></th:block>

<script>

    $('.ui.dropdown').dropdown();


    function deleteBtn(obj) {
        $("#deleteFormId").attr("action",$(obj).data("url")).submit();
    }


</script>
</body>
</html>